#include <iostream>
#include <stdlib.h>
#include "CheckersBoard.h"
#include "CheckersMove.h"
#include "CheckersGame.h"

using namespace std;

void test1()
{
    CheckersBoard cb;
    cb.initializeBoard();
    cb.printBoard();
    cb.calculateLegalMoves(RED);
    cb.printLegalMoves();
    cb.movePiece(cb.getLegalMoves().at(8));
    cb.printBoard();
}

void test2()
{
    CheckersGame cg;
    cg.getCheckersBoard()->printBoard();
    cg.doClickSquare(3,2);
    cg.doClickSquare(4,3);
    cg.getCheckersBoard()->printBoard();
}

void test3(CheckersGame& pGame)
{
    pGame.doClickSquare(6,5);
    pGame.doClickSquare(5,4);
    pGame.doClickSquare(3,8);
    pGame.doClickSquare(4,9);
    pGame.doClickSquare(6,1);
    pGame.doClickSquare(5,0);
    pGame.doClickSquare(2,7);
    pGame.doClickSquare(3,8);
    pGame.doClickSquare(7,2);
    pGame.doClickSquare(6,1);
    pGame.doClickSquare(1,6);
    pGame.doClickSquare(2,7);
    pGame.doClickSquare(8,3);
    pGame.doClickSquare(7,2);
    pGame.doClickSquare(3,4);
    pGame.doClickSquare(4,3);
    pGame.doClickSquare(6,9);
    pGame.doClickSquare(5,8);
}

int main()
{
    //catatan di konstruktor CheckersMove ada cout atributnya :D
    int gameState = PLAYER1_TURN;
    int mRow,mCol;
    CheckersGame cg;

    while (gameState != GAME_END)
    {
        system("cls");
        cout << "currentPlayer: " << cg.getCurrentPlayer() << endl;
        cg.getCheckersBoard()->printLegalMoves();
        cg.getCheckersBoard()->printBoard();
        cout << "pickPiece: " << endl;
        cin >> mRow >> mCol;
        cg.doClickSquare(mRow,mCol);
        cout << "movePiece: " << endl;
        cin >> mRow >> mCol;
        cg.doClickSquare(mRow,mCol);
        if (cg.getCheckersBoard()->getLegalMoves().size() == 0) {
            gameState = GAME_END;
        }
    }
/*
    test3(cg);
    cg.getCheckersBoard()->printBoard();
    cout << "pickPiece: " << endl;
    cin >> mRow >> mCol;
    cg.doClickSquare(mRow,mCol);
    cout << "movePiece: " << endl;
    cin >> mRow >> mCol;
    cg.doClickSquare(mRow,mCol);

    cout << "currentPlayer: " << cg.getCurrentPlayer() << endl;
    cg.getCheckersBoard()->printBoard();
    cout << "movePiece: " << endl;
    cin >> mRow >> mCol;
    cg.doClickSquare(mRow,mCol);

    cout << "currentPlayer: " << cg.getCurrentPlayer() << endl;
    cg.getCheckersBoard()->printBoard();
    cout << "pickPiece: " << endl;
    cin >> mRow >> mCol;
    cg.doClickSquare(mRow,mCol);
    cout << "movePiece: " << endl;
    cin >> mRow >> mCol;
    cg.doClickSquare(mRow,mCol);

    cout << "currentPlayer: " << cg.getCurrentPlayer() << endl;
    cg.getCheckersBoard()->printBoard();
    cout << "pickPiece: " << endl;
    cin >> mRow >> mCol;
    cg.doClickSquare(mRow,mCol);
    cout << "movePiece: " << endl;
    cin >> mRow >> mCol;
    cg.doClickSquare(mRow,mCol);
*/
    cout << "Hello world!" << endl;
    return 0;
}
